package cn.tedu.charging.cost.repository.impl;


import cn.tedu.charging.common.pojo.po.ChargingCostRulePO;
import cn.tedu.charging.cost.mapper.CostRuleMapper;
import cn.tedu.charging.cost.repository.CostRuleRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import javax.management.Query;

@Repository
public class CostRuleRepositoryImpl implements CostRuleRepository {

    @Autowired
    private CostRuleMapper costRuleMapper;


    @Override
    public ChargingCostRulePO getCostRule(Integer stationId, Integer hour) {
        QueryWrapper<ChargingCostRulePO> queryWrapper = new QueryWrapper();
        // station_id = stationId
        queryWrapper.eq("station_id", stationId);
        // start_time <= now  < end_time  ?
        // start_time <= now  <= end_time ?
        // le <=
        queryWrapper.le("start_time",hour);
        // gt 大于 >
        queryWrapper.gt("end_time",hour);
        return costRuleMapper.selectOne(queryWrapper);
    }
}
